home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / puppyred_ball_war.swf / scripts / frame_19 / DoAction.as
Text File  |  2007-09-26  |  5KB  |  190 lines

  1. function powerup()
  2. {
  3.    powerH = 41;
  4.    _root[playname].energy.onEnterFrame = function()
  5.    {
  6.       powerH = 41;
  7.       if(poweron == 1)
  8.       {
  9.          this.p += 2;
  10.          energyH = this.p;
  11.          if(this.p % 3 == 2)
  12.          {
  13.             this.z = this.z + 1;
  14.             this["e" + this.z]._visible = 1;
  15.          }
  16.          if(this.p >= powerH)
  17.          {
  18.             this.p = powerH;
  19.          }
  20.       }
  21.    };
  22. }
  23. function encreat()
  24. {
  25.    if(level < 5)
  26.    {
  27.       enemypoz.attachMovie("level" + level,"level" + level,10);
  28.    }
  29.    else
  30.    {
  31.       enemypoz.attachMovie("level4","level4",10);
  32.    }
  33. }
  34. stop();
  35. dieNum = 0;
  36. over._visible = 0;
  37. alldie = 0;
  38. endieNum = 0;
  39. x = 13;
  40. y = 9;
  41. _root.createEmptyMovieClip("enthrowpoz",10000);
  42. _root.createEmptyMovieClip("throwpoz",1000);
  43. var i = 1;
  44. while(i <= 4)
  45. {
  46.    _root["player" + i].onPress = function()
  47.    {
  48.       if(!this.hit & !this.die)
  49.       {
  50.          this.move = 1;
  51.          this.gotoAndStop("ready");
  52.          playname = this._name;
  53.          _root[playname].attachMovie("energy","energy",10);
  54.          poweron = 1;
  55.          powerup();
  56.       }
  57.    };
  58.    _root["player" + i].onMouseMove = function()
  59.    {
  60.       if(!this.hit & !this.die)
  61.       {
  62.          if(this.move == 1)
  63.          {
  64.             this._x = _xmouse;
  65.             this._y = _ymouse;
  66.             if(this._x > 600)
  67.             {
  68.                this._x = 600;
  69.             }
  70.             if(this._x <= 0)
  71.             {
  72.                this._x = 0;
  73.             }
  74.             if(this._y >= 350)
  75.             {
  76.                this._y = 350;
  77.             }
  78.          }
  79.       }
  80.    };
  81.    _root["player" + i].onMouseUp = function()
  82.    {
  83.       if(!this.hit & !this.die)
  84.       {
  85.          if(this.move == 1)
  86.          {
  87.             this.move = 0;
  88.             this.gotoAndStop("throw");
  89.             poweron = 0;
  90.             _root[playname].energy.removeMovieClip();
  91.             s++;
  92.             if(s > 5)
  93.             {
  94.                s = 1;
  95.             }
  96.             if(this == player1)
  97.             {
  98.                throwNum = 1;
  99.             }
  100.             if(this == player2)
  101.             {
  102.                throwNum = 2;
  103.             }
  104.             if(this == player3)
  105.             {
  106.                throwNum = 3;
  107.             }
  108.             if(this == player4)
  109.             {
  110.                throwNum = 4;
  111.             }
  112.             throwpoz.attachMovie("throw" + throwNum,"throw" + s,s);
  113.             throwpoz["throw" + s]._x = this._x - 20;
  114.             throwpoz["throw" + s]._y = this._y - 10;
  115.             if(!this.hitTest(_xmouse,_ymouse,true))
  116.             {
  117.                this.gotoAndStop(1);
  118.             }
  119.          }
  120.       }
  121.    };
  122.    _root["player" + i].onRollOver = function()
  123.    {
  124.       if(!this.hit & !this.die)
  125.       {
  126.          this.gotoAndStop("over");
  127.       }
  128.    };
  129.    _root["player" + i].onRollOut = function()
  130.    {
  131.       if(!this.hit & !this.die)
  132.       {
  133.          this.move = 0;
  134.          _root[playname].energy.removeMovieClip();
  135.          poweron = 0;
  136.          this.gotoAndStop(1);
  137.       }
  138.    };
  139.    _root["player" + i].onEnterFrame = function()
  140.    {
  141.       if(_root[playname]._y <= - 0.5833333333333334 * _root[playname]._x + 370)
  142.       {
  143.          _root[playname]._y = - 0.5833333333333334 * _root[playname]._x + 370;
  144.          if(_root[playname]._y >= 350)
  145.          {
  146.             _root[playname]._y = 350;
  147.          }
  148.       }
  149.       var r = 1;
  150.       while(r <= 30)
  151.       {
  152.          if(this.hitTest(_root.enthrowpoz["enthrow" + r]._x,_root.enthrowpoz["enthrow" + r]._y,true) & !this.die)
  153.          {
  154.             this.move = 0;
  155.             this.hitNum = this.hitNum + 1;
  156.             _root.enthrowpoz["enthrow" + r].removeMovieClip();
  157.             this.energy.removeMovieClip();
  158.             if(this.hitNum == 1)
  159.             {
  160.                this.gotoAndStop("hit");
  161.                this.hit = true;
  162.             }
  163.             if(this.hitNum >= 2)
  164.             {
  165.                this.gotoAndStop("die");
  166.                this.die = true;
  167.                _root.dieNum = _root.dieNum + 1;
  168.                if(_root.dieNum >= 4)
  169.                {
  170.                   _root.alldie = 1;
  171.                   over._visible = 1;
  172.                   if(_root.score >= 100)
  173.                   {
  174.                      over.gotoAndStop(2);
  175.                   }
  176.                   else
  177.                   {
  178.                      over.gotoAndStop(3);
  179.                   }
  180.                   over.swapDepths(40000);
  181.                }
  182.             }
  183.          }
  184.          r++;
  185.       }
  186.    };
  187.    i++;
  188. }
  189. encreat();
  190.